//
//  KLAutoTrackerOperation.m
//  RKLFoundationFrame
//
//  Created by RKL on 2018/2/11.
//  Copyright © 2018年 AppFrameWorkDemo. All rights reserved.
//

#import "KLAutoTrackerOperation.h"
#import "KLAutoTrackerManager.h"

@implementation KLAutoTrackerOperation

+ (instancetype)sharedInstance
{
    static id _sharedInstance = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _sharedInstance = [[self alloc] init];
    });
    return _sharedInstance;
}

/**
 发送日志
 
 @param eventId 日志id
 @param info 日志内容
 */
- (void)sendTrackerData:(NSString *)eventId info:(NSDictionary *)info
{
    NSDictionary *trackerDictionary = [[NSDictionary alloc] initWithObjectsAndKeys:
                                       eventId.length > 0 ? eventId : @"", KLAutoTrackerEventIDKey,
                                       info ? info : [[NSDictionary alloc] init], KLAutoTrackerInfoKey, nil];
    
    if (eventId.length > 0)
    {
        [[KLAutoTrackerManager sharedInstance] saveToFileWithFileContent:trackerDictionary];
    }
}


@end
